
<%@ page import="report.Plan" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title>iPET - Planejamento</title>
    </head>
    <body>
        <g:render template="/common/menuPlan" />
        <div id="text">
        <div class="body">
            <h2>Lista de planejamentos</h2>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:if test="${planInstanceTotal != 0}">
            <div class="list">
                <table>
                    <thead>
                        <tr>
                            <th class="leftth actions">Ações</th>
                            <g:sortableColumn class="year" property="year" title="${message(code: 'plan.year.label', default: 'Ano')}" />
                            <g:sortableColumn class="rightth" property="observation" title="${message(code: 'plan.observation.label', default: 'Observações')}" />
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${planInstanceList}" status="i" var="planInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                            <td>
                            	<div class="actions">
            						<g:link action="show" controller="plan" id="${planInstance.id}" title="Visualizar"><img alt="Edit" src="${resource(dir:'images/icons',file:'view.png')}" /></g:link>
						            <g:link action="edit" controller="plan" id="${planInstance.id}" title="Editar"><img alt="Edit" src="${resource(dir:'images/icons',file:'edit.png')}" /></g:link>
						            <g:link action="delete" controller="plan" id="${planInstance.id}" title="Excluir" onclick="if (confirm('Esta ação não pode ser desfeita, tem certeza?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;"><img alt="Delete" src="${resource(dir:'images/icons',file:'trash.png')}" /></g:link>
						            <g:link action="plan" controller="pdf" id="${planInstance.id}" title="Relatório" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); return false;"><img alt="Report" src="${resource(dir:'images/icons',file:'report.png')}" /></g:link>
								</div>
                            </td>
                            <td>${planInstance?.year}</td>
                            <td>${fieldValue(bean: planInstance, field: "observation")}</td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${planInstanceTotal}" />
            </div>
            </g:if>
            <g:else>
            	<div class="dialog createBlank">
					<h1><g:link action="create" controller="plan">Cadastre o primeiro planejamento</g:link></h1>
					<p>Quando cadastrado um planejamento, será listado um resumo de informações sobre o mesmo.</p>
				</div>
            </g:else>
        </div>
        </div>
    </body>
</html>
